Hi everybody.
So for this video we still have imparted penned us an umpire from the last video and we also have started
the H column of our Titanic dataset and the variable H.
And we have our H panda serious within the marital values so we can also check again if our H serious
has an American values so it has its float objects.
That's true and now we want to further analyze our H column R. H.
Pandas areas and in the last video we already applied them the very powerful method describe them that
return to us here.
The number of non low values that the mean standard deviation Max and so on and we can also call all
of these summary statistics.
A single method.
So for example here we have the count method
and the count method that gives us all nominal values of our pandas series.
So that's the press shift tap here.
Return number from animal values and observations in our series.
All right so let's go on and try the attribute size and check with the shift tab.
So the attribute size the returns are the number of elements in our serious so obviously also including
missing value.
So any anywhere you saw also included here in the attribute size so the differentiate between count
and sizes then that count does not include all missing values and we can also pass them our age pandas
serious to the Python burden and function length.
And here we get eight hundred ninety one elements in our pandas areas including missing values and we
can also take the sum of all elements in our pandas serious age.
So it's twenty one thousand.
Here in the case of our H column so the sun doesn't really make sense.
But I want to show you here and highlight the difference to the past and build and function some so
we can pass our pandas serious here to the sum function
and you will get an A and so this stands for our number terminal or our non value actually.
And why is this the case.
Because then the pace and burden function some cop cannot handle missing values and in contrast then
the method some can handle missing the missing values and you can see here by pressing shift tab that
by default that is a parameter call it skip and a check here.
Here it is.
And uh by default that's true.
So it excludes uh and a null values when computing the result.
So we can also try it here skip and a and by default it's true so by default and some method to skips
and a values missing values and still we get here twenty one thousand but if we do not skip and a values
then also a year we get the non selection panels cannot calculate the sum year because we have uh low
values of missing values and now we're serious and they actually they you can see the power of the pandas
to the library of that it's specifically designed for handling real world data where we have they are
typically many missing values and by default in most of the cases pandas just yet ignores actually the
missing values.
All right so now let's go over to the method mean.
So the mean method obviously calculates the average or the mean value of our pandas serious.
So the average peasant job was at twenty nine point six years old.
And also here we have the parameter skip and a.
So and by default it's uh set to true and B could also change this to forms and include the missing
values and to our mean calculation and then we get normal.
So you're by default and the and a values are ignored actually.
And that's that's good actually for us because on most of the cases we have and a values and they are
we should ignore it like when we calculate the mean values and that's also the method the standard deviation
which calculates them the standard deviation and also that is a method that returns us to the minimum
value in our pandas series.
So we already know there was a passenger that was only 0.01 two years old and with the max method we
can get them.
Actually the oldest passenger on board of the Titanic and he was 80 years old.
And there's also the P2P method and we can check here pressing shift tab.
So this returns and the difference between the maximum value and the minimum value in our panda serious.
So obviously the maximum value is 80 and the minimum 0.01 too.
So we should get the difference here and it's seventy nine point five eight and with the median method
we can get to the median of our pandas serious it's twenty eight years
and now we are coming to the very powerful a unique method and the unique method is one of the methods
then that are exclusively only available for pandas serious but not for panda data friends so we can
run near the site and have a look and we can also check here with the shift tab.
So the unique method returns unique values of our series object
so this are actually the unique value.
So in total we have 800 uh 91 percent just.
But these are the unique ages actually.
So we have for example passengers that are 22 years old and we have passengers that are 38 years old
and you have the next question would be how many unique values do we have.
And we can apply here the length function and we get eighty nine unique values and as you can see here
by applying the unique method also missing values and values are included so eighty nine here should
be all unique values including missing values and with the end unique method we can also count the number
of unique values and it's eighty eight.
So by default the end unique method excludes missing or any end values.
But if you press shift tab here you can also see here that there apparently the drop and a.
And by default that's true.
So it ignores the missing values.
And if we switch here to fours we also got eighty nine unique values because now also the end they end
on missing values are included.
All right so next we come to the also very helpful and yes super power powerful method.
Value counts and with the value counts.
Let's run here and check here shift tab.
So value counts the returns here an object containing counts of unique value is and the resulting object
will be in descending order so that the first element is the most frequently occurring element.
So let's see here on the left side are the values of our panel series.
So we have passengers who are 24 years old and 22 year old and 25 years is actually the most frequent.
Value in our panel series.
So there were actually 30 passengers on the Titanic that were 24 years old.
And and there were 27 passengers and that were 22 years old.
And we can scroll down here and in the end we can see that.
There's only one passenger who is uh.
Point 4 2 years old and uh for example uh there's only one passenger service.
Seventy 74 years and also value counts by default ignores the missing or any end well.
So actually you're the default parameter set to true.
But we can actually change this to Ford's
and then we can see we have from the value counts including missing values and at the top.
We have here one hundred seventy seven missing values and you can also see that by default value counts.
Returns um a new series with a slotted values.
So the most frequent value is at the top end.
The less frequent values are at the bottom here of our new panel areas.
And we can also change for this year.
And that is a parameter quite smart and we can set this to false.
So by default these sort parameter is true.
And let's see what we get here.
We got actually here the unsorted uh value count serious starting from uh 22 years old.
So this is actually the first value in our H.
Serious.
And 27 percent just 22 years old.
So but it definitely makes sense to authority our aside.
So let's again change it to true
and you can see here that we have a descending order so starting with the most frequent number of value
and we can also change this by setting the ascending parameter which is by default to set to false and
we can set this to true.
Now we have an ascending order starting with the less frequent values of our H serious so in the most
cases for our analyzing purposes it makes more sense to have a look at the most frequent items here.
All right.
And that's a not the parameter quite normalized.
So here we effort the absolute numbers are amounts our counts of our values and we can normalize this.
So sample here and 30 percent just at 24 years old and we can normalize 30.
So we can divide this by the total number of passengers.
It's the net seven a look here
we have actually 714 peasant us where we know the H
and by setting here the normalized parameter to true we should get here 30 divided by 714 so let's check
it here.
So now you do not get the absolute quantities but the relative quantities.
So still 24 year olds and the most frequent value and actually 5.2 percent of all passengers were 24
years old.
And because we have to drop an equal to the missing values were excluded for this calculation.
But we can change this also.
And last but not least.
There's another parameter for our value counts uh method and this has been slow let's have a look here
press shift tab
and what the pins does them rather than count values that groups them into half open bins and let's
see what we get here
so we get to your five bins.
Um yeah actually with equal lengths so starting from 0 point fifty nine and ten sixteen years and ending
with them the oldest pin from 64 years to eighty years.
And for each pin we get the amount of values that are in our H a serious so we have eleven passengers
that are between 64 and 80 years old and the most frequent pin here is between 16 and 32 years old.
So 346 passengers are between 16 and 32.
All right so now we have finished the analysis of our numerical serious and in the next session we will
have to look at the non numerical serious so hope to see there by.